layui.use(['form','layer','laydate','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;

    //订单列表
    var tableIns = table.render({
        elem: '#queryTable',
        url : '/iprint/admin/searchOrders',
        method:'get',
        request:{
            pageName: 'currPage' //页码的参数名称，默认：page
            ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
        },
        where:{
            queryStatus:'0'
        },
        response: {
            statusName: 'status' //数据状态的字段名称，默认：code
            ,statusCode: 200 //成功的状态码，默认：0
            ,countName: 'totalCount' //数据总数的字段名称，默认：count
            ,dataName: 'list' //数据列表的字段名称，默认：data
        },
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limit : 20,
        limits : [10,15,20,25],
        id : "queryTable",
        cols : [[
            {field: 'id', title: '订单id', width:120, align:"center"},
            {field: 'title', title: '订单类型', align:'center',templet:"#newsStatus"},
            {field: 'count', title: '数量', align:'center'},
            {field: 'total', title: '总金额',  align:'center'},
            {field: 'pageType', title: '纸张类型', align:'center'},
            {field: 'pageSize', title: '纸张尺寸', align:'center'},
            {field: 'singleDouble', title: '单双面', align:'center', minWidth:110},
            {field: 'printType', title: '打印类型', align:'center', minWidth:110},
            {field: 'margin', title: '边距', align:'center', minWidth:110},
            {field: 'craftwork', title: '工艺', align:'center', minWidth:110},
            {field: 'changBgc', title: '底色', align:'center', minWidth:110},
            {field: 'pageWeight', title: '纸张重量', align:'center', minWidth:110},
            {title: '操作', width:120, templet:'#newsListBar',fixed:"right",align:"center"}
        ]]
    });

    //日期范围
    laydate.render({
        elem: '#daterange'
        ,type: 'datetime'
        ,range: true
    });
    //自定义验证规则
    form.verify({
        mynum: [/^$|^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/, '金额必须是正数'],
        orderid: [/^$|^[0-9]*[1-9][0-9]*$/, '订单ID必须是数字或空']
    });
    //查询表格提交
    form.on('submit(sub)', function(data) {
        var parm = JSON.stringify(data.field);
        //重载表格
        table.reload("queryTable",{
            where: JSON.parse(JSON.stringify(data.field)),
            url : '/iprint/admin/searchOrders'
        });
        return false;
    });
})